forum

home / developersection / forums / how to get handle to the window in wpf?

How to get handle to the window in wpf?

Anonymous User 3124 23-Sep-2013

I got a WPF project, which is compiled into a dll and will be called from another application. That's how it is set up. In this WPF project I need to pop up a customized message box from the view model of the main window to show messages to the user. This customized message box requires a Window parameter. That's how it is.

For a WPF application, Application.Current.MainWindow will get me what I need. But here it is a dll, so Application.Current is null, and leads to run time exception. I also tried something like Window.GetWindow(this). Here it is not working, because 'this' is the view model, so it won't give me the handle of the main window.

What else can I try to get the handle of the main window here?

Thanks.


wpf wpf 
Updated on 23-Sep-2013

I am a content writter !


Message
Can you answer this question?

Answer

1 Answers

Liked By